<template>
    <!-- 测量控制点移交 -->
    <base-breadcrumb :title="$route.meta.title">
        <!-- 搜索 -->
        <searchData :searchData="searchArr" @search="search"></searchData>
        <!-- 表格 -->
        <a-card :bordered="false">
            <!-- <title-name :title="$route.meta.title"></title-name> -->
            <a-button class="mb12" icon="plus" type="primary" @click="handleManage(2)" v-btnPermission="'tm_025_add_01'">新增</a-button>
            <!-- 表格 -->
            <list-table
                ref="table"
                tableLayout="fixed"
                size="default"
                rowKey="id"
                :columns="columns"
                :request="loadData"
                :page-keys="['pageNum', 'pageSize','totalSize']"
                :alert="true"
                show-size-changer
                show-quick-jumper
                showPagination="auto">
                <template slot="transferType" slot-scope="text">
                    {{text*1===0?'甲方移交给施工单位':'施工单位移交给分包单位'}}

                </template>
                <template slot="action" slot-scope="text, record">
                    <MoreButton>
                    <a @click="handleManage(0, record)" v-btnPermission="'tm_025_loo_04'">查看</a>
                    <span v-btnPermission="'tm_025_edi_02'" >
                        <a @click="handleManage(1, record)">编辑</a>
                        </span>
                    <!-- 删除 -->
                    <span v-btnPermission="'tm_025_del_03'">
                        <a @click="handleRemoveParams({ id: record.id})">删除</a>
                    </span>
                    </MoreButton>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { getTransferConstructionSurveyControlPointList, deleteTransferConstructionSurveyControlPoint} from '@/api/technical/controlPointHandover' // api
import BasePage from '@/views/basePage' // 基础配置
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import OrgTreeSelect from '@/components/OrgTreeSelect'
import { transferTypeData } from './model'
const searchArr = [
    // 搜索框
    {name: '所属单位', valueKey: 'searchQuery', type: OrgTreeSelect},
    // {name: '所属分公司', valueKey: 'branchCompanyId', type: SelectSubCompany},
    // {name: '所属项目',keyValue: 'branchCompanyId',valueKey: 'projectId',type: SelectProject},
    {name: '移交类型',type: 'select', value: 'transferType', data: transferTypeData},
    {name: '移交单位',type: 'input', value: 'transferUnit'},
    {name: '移交人',type: 'input', value: 'transferPerson'},
    {name: '接收单位',type: 'input', value: 'recvUnit'},
    {name: '接收人',type: 'input', value: 'recvPerson'},
    {name: '移交时间',type: 'dateRange',value: 'transferTime',
    attr: {
            rangeFormat: ['updateStartTime', 'updateEndTime']
        }
    },
]

const columns = [
    {title: '序号',width: 80,dataIndex: 'index',
        customRender() {
            return arguments[2] + 1
        }
    },
    {title: '所属分公司',dataIndex: 'branchCompanyName',ellipsis: true,width: 150,},
    {title: '所属项目',dataIndex: 'projectName',ellipsis: true,width: 150,},
    {title: '移交类型',dataIndex: 'transferType',ellipsis: true,width: 200,scopedSlots: { customRender: 'transferType' }},
    {title: '移交单位',dataIndex: 'transferUnit',ellipsis: true,width: 150,},
    {title: '移交人',dataIndex: 'transferPerson',ellipsis: true,width: 180,},
    {title: '接收单位',dataIndex: 'recvUnit',ellipsis: true,width: 180,},
    {title: '接收人',dataIndex: 'recvPerson',ellipsis: true,width: 180,},
    {title: '楼栋及工程部位',dataIndex: 'buildingAndProjectLocation',ellipsis: true,width: 180,},
    {title: '移交时间',dataIndex: 'transferTime',ellipsis: true, width: 200,},
    {title: '操作',dataIndex: 'action',width: '280px',align: 'center',scopedSlots: { customRender: 'action' },  fixed: 'right',}
]
export default {
    name: 'a' + Date.now(),
    extends: new BasePage(),
    components: {
        STable
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {}, // 查询参数
            loadData: async (parameter) => {
                const requestParameters = Object.assign({}, parameter, { param: this.queryParam })
                return getTransferConstructionSurveyControlPointList(requestParameters).then((res) => {
                    return {
                            code: 200,
                            data: res.data.list,
                            totalSize: res.data?.total,
                            currentPage: res.data?.pageNum
                    }
                })
            },
            removeApi: { remove: deleteTransferConstructionSurveyControlPoint },// api
            SummaryData:{
                confirmAmountHas:0,
                correspondingCostHaveVat:0,
                number:0,
                profitRate:0,
                submitMoneyHaveVat:0
            }    //汇总
        }
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            let query = {
                editModel: type
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: 'updateControlPointHandover',
                query
            })
        }
    },
}
</script>
